package com.ecoolex.ying.space.api.graphql;

import com.ecoolex.framework.modularize.api.auth.user.ConsumerMemberAuthority;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.MutationField;
import com.ecoolex.ying.space.ws.DesignerProjectService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

@GraphQL2Module(type = GraphQL2Module.Type.User, description = "用户优选商品收藏管理")
public class UserPickGoodsFavoriteGraphql {

    @Reference
    private DesignerProjectService designerProjectService;

    @MutationField(field = "addUserPickGoodsFavorite", description = "添加用户优选商品收藏")
    public boolean addPickGoodsFavorite(@NonNull Integer pickGoodsId, ConsumerMemberAuthority user) {
        user.assertLogin();
        designerProjectService.addPickGoodsFavorite(user.userId(), pickGoodsId, user.userName());
        return true;
    }

    @MutationField(field = "delUserPickGoodsFavorite", description = "删除用户优选商品收藏")
    public boolean deletePickGoodsFavorite(@NonNull Integer pickGoodsId, ConsumerMemberAuthority user) {
        user.assertLogin();
        designerProjectService.deletePickGoodsFavorite(user.userId(), pickGoodsId, user.userName());
        return true;
    }
}
